package com.ttloner.service.impl;

import com.ttloner.dao.impl.UserDAO;
import com.ttloner.dao.impl.UserDAOImpl;
import com.ttloner.pojo.User;
import com.ttloner.utils.JDBCUtils;

import java.sql.Connection;

/**
 * @author TTLoner
 * @date 2021/7/6 11:22
 * @description
 */
public class UserServiceImp implements UserService{
    private UserDAO userDao=new UserDAOImpl();
    @Override
    public int registUser(User user) {
        int dealNum = userDao.saveUser(user);
        return dealNum;
    }

    @Override
    public User login(User user) {
        User userOut = userDao.queryUserByUsernameAndPassword(user.getUsername(), user.getPassword());
        return userOut;
    }

    @Override
    public boolean existUsername(String username) {
        User user = userDao.queryUserByUsername(username);
        if(user==null) return true;
        return false;
    }
}
